<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>输入与点击输出</title>
    <script src="../../js/vue3.js"></script>
    <style>
        #app {
            margin: 2rem auto;
            width: 50%;
            text-align: center;
        }
        
        p {
            font-size: 1.5rem;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="app">
        <input type="button" value="btn1" @click="btn1Click">
        <input type="button" value="btn2" @click="btn2Click(num,$event)">
        <input type="text" v-model="price" @input="input1($event)">
        <input type="text" v-model="num2"> {{sum}}
    </div>
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    num: 0,
                    price: 0,
                    num2: 0
                }
            },
            computed: {
                sum() {
                    return this.price * this.num2
                }
            },
            methods: {
                btn1Click(event) {
                    console.log(event);
                    console.log(event.target)
                },
                btn2Click(num, event) {
                    console.log(num)
                    console.log(event);
                    console.log(event.target)
                    console.log(event.target.name)
                },
                input1(val) {
                    console.log(val);
                    console.log(val.target);
                    console.log(val.target.value)
                }

            },

        })
        app.mount("#app")
    </script>
</body>

</html>